add_subdirectory(themes)

set(CLASSICUI_WAYLAND_SRCS)
set(CLASSICUI_WAYLAND_LIBS)
if (WAYLAND_FOUND)
    set(CLASSICUI_WAYLAND_SRCS ${CLASSICUI_WAYLAND_SRCS}
        waylandui.cpp waylandwindow.cpp waylandshmwindow.cpp
        waylandpointer.cpp buffer.cpp waylandinputwindow.cpp)
    set(CLASSICUI_WAYLAND_LIBS ${CLASSICUI_WAYLAND_LIBS}
        Fcitx5::Module::Wayland Fcitx5::Module::WaylandIM Wayland::Client Fcitx5::Wayland::Core
        Fcitx5::Wayland::InputMethod Fcitx5::Wayland::InputMethodV2
        Fcitx5::Wayland::Blur)
else()
endif()

if (ENABLE_X11)
    set(CLASSICUI_WAYLAND_SRCS ${CLASSICUI_WAYLAND_SRCS}
        xcbui.cpp xcbwindow.cpp xcbtraywindow.cpp xcbinputwindow.cpp xcbmenu.cpp)
    set(CLASSICUI_WAYLAND_LIBS ${CLASSICUI_WAYLAND_LIBS} PkgConfig::CairoXCB Fcitx5::Module::XCB
        XCB::AUX XCB::ICCCM XCB::XINERAMA XCB::RANDR XCB::EWMH)
endif()

if (ENABLE_DBUS)
    set(CLASSICUI_LIBS ${CLASSICUI_LIBS} Fcitx5::Module::DBus)
endif()
find_package(PkgConfig REQUIRED)
if (PKG_CONFIG_FOUND)
       pkg_check_modules(Cairo REQUIRED IMPORTED_TARGET cairo)
       pkg_check_modules(Pango REQUIRED IMPORTED_TARGET pango)
       pkg_check_modules(GdkPixbuf REQUIRED IMPORTED_TARGET gdk-pixbuf-2.0)
       pkg_check_modules(GioUnix REQUIRED IMPORTED_TARGET gio-unix-2.0)
       MESSAGE(STATUS "Cairo_INCLUDE_DIRS:${Cairo_INCLUDE_DIRS}")
       MESSAGE(STATUS "Pango_INCLUDE_DIRS:${Pango_INCLUDE_DIRS}")
       MESSAGE(STATUS "GdkPixbuf_INCLUDE_DIRS:${GdkPixbuf_INCLUDE_DIRS}")
        message(STATUS "GioUnix_INCLUDE_DIRS:${GioUnix_INCLUDE_DIRS})")
endif()
INCLUDE_DIRECTORIES(
       ${Cairo_INCLUDE_DIRS} 
       ${Pango_INCLUDE_DIRS}
       ${GdkPixbuf_INCLUDE_DIRS}
       ${GioUnix_INCLUDE_DIRS})


add_library(classicui MODULE
    classicui.cpp window.cpp theme.cpp inputwindow.cpp plasmathemewatchdog.cpp ${CLASSICUI_WAYLAND_SRCS}
    )

target_link_libraries(classicui
    Fcitx5::Core
    PkgConfig::Cairo PkgConfig::Pango
    PkgConfig::GdkPixbuf PkgConfig::GioUnix
    Fcitx5::Module::NotificationItem
    ${CLASSICUI_WAYLAND_LIBS}
    ${FMT_TARGET})
install(TARGETS classicui DESTINATION "${FCITX_INSTALL_ADDONDIR}")
configure_file(classicui.conf.in.in classicui.conf.in @ONLY)
fcitx5_translate_desktop_file(${CMAKE_CURRENT_BINARY_DIR}/classicui.conf.in classicui.conf)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/classicui.conf" DESTINATION "${FCITX_INSTALL_PKGDATADIR}/addon"
        COMPONENT config)

fcitx5_export_module(ClassicUI TARGET classicui BUILD_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}" HEADERS classicui_public.h)
